2019/9/1

Time Series Simulation

At First we will simulate two time series.

  • generate two random stochastic processes
  • generate a cointegration series
  • statistical tesy and ADF test

Code

library(plotly)
library(tidyverse)

set.seed(42)
N = 1000
x = cumsum(rnorm(N))
gamma = 0.7
y = gamma * x + rnorm(N)

Plot with Plotly

Statistical Test

Now we will use ADF-test for check the stationarity by urca package.

library(urca)

summary(ur.df(x, type = 'none'))
summary(ur.df(y, type = 'none'))

From the result we cannot reject H0 hypothesis that two series are unit root process.

Linear Combination and ADF-test

In this part we will generate a linear combination series with x and y. Then we will use ADF-test on this new series.

z = y - gamma * x
ur.df(z, type='none')
## 
## ############################################################### 
## # Augmented Dickey-Fuller Test Unit Root / Cointegration Test # 
## ############################################################### 
## 
## The value of the test statistic is: -22.2053

Now we can see this combination series is stationarity.

Plot of Z series